<?php

namespace backend\controllers;

class ThemesController extends \yii\web\Controller
{
    public function actionIndex()
    {
        
        
        $themePath = dirname(\Yii::$app->basePath).DIRECTORY_SEPARATOR."frontend".DIRECTORY_SEPARATOR."views";

        $dirs= scandir($themePath);

        $themes = [];

        foreach($dirs as $dir ){

            if((strpos($dir,".") === false)){


                if(file_exists($themePath.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR."cover.jpg")){

                    $theme = ['name'=>$dir,'cover.jpg'];
                    $themes[] = $theme;
                }

            }

        }

//        
//        echo "<pre>";
//        print_r($themes);exit;
        


        return $this->render('index',[            
            'themes' =>$themes
        ]);
    }

}
